# coding=utf-8
import json
class LayuiTableMsg():
    # data:数据，类型是object[]，必须实现to_json_string函数
    # code:成功则为0
    # msg:错误提示
    def __init__(self, data, code=0, msg=''):
        self.data = data
        self.count = len(data)
        self.code = code,
        self.msg = msg

    # 将对象转为json字符串
    def to_json_string(self):
        return json.dumps( self.__to_dict__())

    # 将对象转为字典对象
    def __to_dict__(self):
        return {
            'data': [obj.to_dict() for obj in self.data] ,
            'count':self.count,
            'code':self.code,
            'msg':self.msg,
        }
